package company.xiaomi;

import java.util.Scanner;

public class Mi2 {

    static boolean result = false;

    public static void main(String[] args) {
        char[][] dict = new char[][]{
                {'A', 'B', 'C', 'E'},
                {'S', 'F', 'C', 'S'},
                {'A', 'D', 'E', 'E'}
        };
        int[][] used = new int[3][4];
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        if (s.trim().length() == 0) {
            System.out.println(false);
            return;
        }
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 4; j++) {
                helper(0, s, dict, i, j, used);
            }
        }
        System.out.println(result);
    }

    private static void helper(int index, String s, char[][] dict, int x, int y, int[][] used) {
        if (result || x < 0 || x >= 3 || y < 0 || y >= 4)
            return;
        if (index == s.length()) {
            result = true;
            return;
        }
        char c = s.charAt(index);
        if (dict[x][y] == c && used[x][y] == 0) {
            used[x][y] = 1;
            helper(index + 1, s, dict, x + 1, y, used);
            helper(index + 1, s, dict, x - 1, y, used);
            helper(index + 1, s, dict, x, y + 1, used);
            helper(index + 1, s, dict, x, y - 1, used);
            used[x][y] = 0;
        }
    }
}
